package com.clkj.xiuzheng.dao.shangcheng;

import com.clkj.xiuzheng.pojo.shangcheng.TopicComment;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.springframework.stereotype.Repository;
import tk.mybatis.mapper.common.Mapper;

import java.util.List;

/**
 * @author yawang
 * @create 2024/05/20 10:14:27
 **/
@Repository
public interface TopicCommentMapper extends Mapper<TopicComment> {

    @Select("select a.*,b.user_name,b.user_img from t_xz_topicComment a left join t_xz_user b on a.user_id = b.user_id where a.topic_id = #{topicId} order by comment_id desc")
    List<TopicComment> listComment(@Param("topicId")Integer topicId);

    @Select("<script>" +
            "select a.*,b.user_name,b.user_img,c.baike_title from t_xz_topicComment a left join t_xz_user b on a.user_id = b.user_id " +
            "left join t_xz_topicOrVideo c on a.topic_id = c.baike_id  where 1=1 " +
            "<if test='topicId!=0'> and a.topic_id = #{topicId}</if>" +
            "  order by comment_id desc" +
            "</script>")
    List<TopicComment> listAllComment(@Param("topicId")Integer topicId);
}
